<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.js"></script>
</head>
<body>
<h3>已安装插件</h3>
<table border="1">
    <tr>
        <th>插件名称</th>
        <th>版本</th>
        <th>启用</th>
        <th>操作3</th>
    </tr>
    <#list items="${havePlugins}" var="plugin">
        <tr>
            <td>${plugin.name}</td>
            <td>${plugin.version}</td>
            <td>
                <c:if test="${plugin.active == true}">
                    <input type="checkbox" checked="checked" onchange="active(this,${plugin.id})" value="" />
                </c:if>
                <c:if test="${plugin.active == false}">
                    <input type="checkbox" checked="checked" onchange="active(this,${plugin.id})" value="" />
                </c:if>

            </td>

            <td>
                <a href="#">更新</a> |<a href="#">卸载</a>| <a href="#">控制台</a>
            </td>

        </tr>
    </#list>
</table>
</body>

<script type="text/javascript">
    function active(checkBox,id){
        var check=$(checkBox).prop('checked');
        <!--TODO 需要加上 项目上下文 -->
        if(check){
            $.get("/plugin?action=active&id="+id,function(data,status){
                alert(data);
            });
        }else{
            $.get("/plugin?action=disable&id="+id,function(data,status){
                alert(data);
            });
        }
    }
</script>
</body>
</html>